package com.rupertjones.globalcron.domain;

import org.joda.time.DateTime;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * <p>&copy Rupert Jones 2011</p>
 *
 * @author rup
 */
@Repository
public class JobExecutionLogDAO extends AbstractHibernateDAO<JobExecutionLog> {
    public JobExecutionLogDAO() {
        super(JobExecutionLog.class);
    }

    public Collection<JobExecutionLog> findAllSince(DateTime when) {
        List<JobExecutionLog> matched = new ArrayList<JobExecutionLog>();

        for (JobExecutionLog log : findAll()) {
            if (log.getLastModified().after(when.toDate())) {
                matched.add(log);
            }
        }

        return matched;
    }
}
